home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swags_z.zip / STRINGS.SWG / 0040_Locate SubStr at Right.pas < prev    next >
Pascal/Delphi Source File  |  1993-09-26  |  971b  |  24 lines

  1. {*****************************************************************************
  2.  * Function ...... InStrR
  3.  * Purpose ....... To locate a substring in a string starting at a given
  4.  *                 position from the right of the string.
  5.  * Parameters .... n        Position in the string to start searching
  6.  *                 sub      Substring to search for
  7.  *                 s        String to search in
  8.  * Returns ....... Numeric position of <sub> in string <s> after position <n>
  9.  *                 from right to left.
  10.  * Notes ......... Uses function Right
  11.  * Author ........ Martin Richardson
  12.  * Date .......... October 2, 1992
  13.  *****************************************************************************}
  14. FUNCTION InStrR( n: BYTE; sub: STRING; s: STRING ): BYTE;
  15. VAR i: INTEGER;
  16. BEGIN
  17.      i := POS( sub, Right( s, LENGTH(s)-n+1 ) ) + n - 1;
  18.      IF i = 0 THEN
  19.          InStrR := i
  20.      ELSE
  21.          InStrR := LENGTH( s ) - i + 1;
  22. END;
  23.  
  24.